Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@unified-latex/unified-latex-util-trim

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unified-latex/unified-latex-util-trim

Functions for modifying a unified-latex AST

  • 1.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

unified-latex-util-trim

What is this?

Functions to help modify a unified-latex Abstract Syntax Tree (AST).

When should I use this?

If you want to remove whitespace from the ends of an array of nodes.

Note that whitespace can come from a Ast.Whitespace node or from an Ast.Comment node that has leading whitespace. These functions take care to deal with both situations.

Install

npm install @unified-latex/unified-latex-util-trim

This package contains both esm and commonjs exports. To explicitly access the esm export, import the .js file. To explicitly access the commonjs export, import the .cjs file.

Plugins

unifiedLatexTrimEnvironmentContents

Unified plugin to trim the whitespace from the start/end of any environments, including math environments.

Usage

unified().use(unifiedLatexTrimEnvironmentContents)

Type

Plugin<void[], Ast.Root, Ast.Root>

function unifiedLatexTrimEnvironmentContents(): (tree: Ast.Root) => void;

unifiedLatexTrimRoot

Unified plugin to trim the whitespace from the start/end of the root element.

Usage

unified().use(unifiedLatexTrimRoot)

Type

Plugin<void[], Ast.Root, Ast.Root>

function unifiedLatexTrimRoot(): (tree: Ast.Root) => void;

Functions

hasWhitespaceEquivalent(nodes)

Returns whether the array has whitespace at the start/end. Comments with leadingWhitespace === true are counted as whitespace. Other comments are ignored.

function hasWhitespaceEquivalent(nodes: Ast.Node[]): {
  start: boolean;
  end: boolean;
};

Parameters

ParamType
nodesAst.Node[]

trim(nodes)

Trims whitespace and parbreaks from the start and end of an array. The number of trimmed nodes is returned. Special care is taken to preserve comments, though any whitespace before the first comment(s) or after the last comment(s) is trimmed.

function trim(nodes: Ast.Node[]): { trimmedStart: number; trimmedEnd: number };

Parameters

ParamType
nodesAst.Node[]

trimEnd(nodes)

Trim whitespace and parbreaks from the right of an array.

function trimEnd(nodes: Ast.Node[]): { trimmedEnd: number };

Parameters

ParamType
nodesAst.Node[]

trimStart(nodes)

Trim whitespace and parbreaks from the left of an array.

function trimStart(nodes: Ast.Node[]): { trimmedStart: number };

Parameters

ParamType
nodesAst.Node[]

Keywords

FAQs

Package last updated on 22 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc